package http

import (
	"io/ioutil"
	"net/http"
	"strings"
)

func httpGet(url string) string {
	resp, err := http.Get(url)
	if err != nil {
		return "http.Get error"
	}

	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "ioutil.ReadAll error"
	}

	return string(body)
}

func httpPost() string {
	resp, err := http.Post("https://api.juejin.cn/recommend_api/v1/article/recommend_article_detail_feed?aid=2608&uuid=7035080842428106251",
		"application/x-www-form-urlencoded",
		strings.NewReader("name=cjb"))
	if err != nil {
		return "http.Post error"
	}

	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return "ioutil.ReadAll error"
	}

	return string(body)
}
